import logging

import config


class TenderApi:

    def __init__(self, session):
        # 接收session对象的变量
        self.session = session

    # 投资接口
    def tender(self, temp_id, amount):
        url = config.BASE_HOST + "/trust/trust/tender"
        body = {
            "id": temp_id,
            "depositCertificate": -1,
            "amount": amount
        }
        response = self.session.post(url=url, data=body)
        logging.info(f"投资接口返回值：{response.text}")
        return response

    # 第三方投资接口
    def third_tender(self, url, from_action):
        resp = self.session.post(url=url, data=from_action)
        logging.info(f"第三方投资接口返回值：{resp.text}")
        return resp
